<!doctype html>
<html>
<head>
    <script src="../js/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp">

    <div ng-controller="MyController">
        <input ng-model="to"
               type="email"
               placeholder="Recipient"/>
        <textarea ng-model="emailBody"></textarea>
        <pre>{{ previewText }}</pre>
    </div>

</div>
<script type="text/javascript">

    var app = angular.module("myApp", []);
    app.controller('MyController', function ($scope, $interpolate) {
        $scope.$watch('emailBody', function (body) {
            if (body) {
                var template = $interpolate(body);
                $scope.previewText =
                        template({to: $scope.to});
            }
        });
    });

</script>
</body>
</html>